package org.qly.springboot_1.Controller;

import org.qly.springboot_1.Mapper.ArticleMapper;
import org.qly.springboot_1.domain.Article;
import org.qly.springboot_1.domain.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Controller
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleMapper articleMapper;
    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<Article> articleList = articleMapper.findAll();
        model.addAttribute("articleList",articleList);
        return "articleList";
    }
    @RequestMapping("/findById")
    public String findById(int id,Model model){
        List<Comment> comment = articleMapper.findById(id);
        model.addAttribute("article",comment);
        return "articleDetail";
    }
}

